/** * Rubicon Project: Solutions Engineering * Client: 10850/Newsquest UK * Name: rp-newsquest-mapping.js * Author: Martin Hill * Version: 1.0 * Description: First Party Data Mapping Script **/ // add indexOf for arrays for browsers that don't have native support, i.e. IE < 9. if (!Array.prototype.indexOf) { Array.prototype.indexOf = function(item) { var i = this.length; while (i--) { if (this[i] === item) return i; } return -1; } } // add array forEach function for browsers that don't have native support, i.e. IE < 9. if (!Array.prototype.forEach) { Array.prototype.forEach = function(fun /*, thisArg */) { "use strict"; if (this === void 0 || this === null) throw new TypeError(); var t = Object(this); var len = t.length >>> 0; if (typeof fun !== "function") throw new TypeError(); var thisArg = arguments.length >= 2 ? arguments[1] : void 0; for (var i = 0; i < len; i++) { if (i in t) fun.call(thisArg, t[i], i, t); } }; } // add JSON.stringify & parse functions for browsers that don't have native support, i.e. IE < 8. if (!window.JSON) { window.JSON = { parse: function (sJSON) { return eval("(" + sJSON + ")"); }, stringify: function (vContent) { if (vContent instanceof Object) { var sOutput = ""; if (vContent.constructor === Array) { for (var nId = 0; nId < vContent.length; sOutput += this.stringify(vContent[nId]) + ",", nId++); return "[" + sOutput.substr(0, sOutput.length - 1) + "]"; } if (vContent.toString !== Object.prototype.toString) { return "\"" + vContent.toString().replace(/"/g, "\\$&") + "\""; } for (var sProp in vContent) { sOutput += "\"" + sProp.replace(/"/g, "\\$&") + "\":" + this.stringify(vContent[sProp]) + ","; } return "{" + sOutput.substr(0, sOutput.length - 1) + "}"; } return typeof vContent === "string" ? "\"" + vContent.replace(/"/g, "\\$&") + "\"" : String(vContent); } }; } // sessionstorage / cookie set function n = name, v = value, x = expiry (days) rpsc = function(n,v,x) { if (typeof sessionStorage !== 'undefined') { sessionStorage.setItem(n,v); } else { var xd = new Date(); xd.setDate(xd.getDate() + x); var cv = escape(v) + ((xd === null) ? '' : '; expires=' + xd.toUTCString()); document.cookie = n + '=' + cv; } } region = { '' : '', '/' : '', 'alloaadvertiser.com' : 'scotland', 'ardrossanherald.com' : 'scotland', 'ayradvertiser.com' : 'scotland', 'barrheadnews.com' : 'scotland', 'bordertelegraph.com' : 'scotland', 'centralfifetimes.com' : 'scotland', 'dunfermlinepress.com' : 'scotland', 'eastlothiancourier.com' : 'scotland', 'stirlingnews.co.uk' : 'scotland', 'strathallantimes.co.uk' : 'scotland', 'peeblesshirenews.com' : 'scotland', 'troontimes.com' : 'scotland', 'carrickherald.com' : 'scotland', 'cumnockchronicle.com' : 'scotland', 'irvinetimes.com' : 'scotland', 'largsandmillportnews.com' : 'scotland', 'clydebankpost.co.uk' : 'scotland', 'dumbartonreporter.com' : 'scotland', 'greenocktelegraph.co.uk' : 'scotland', 'helensburghadvertiser.co.uk' : 'scotland', 'the-gazette.co.uk' : 'scotland', 'bmgevents.co.uk' : 'scotland', 'businessreviewberkshire.co.uk' : 'scotland', 'impartialreporter.com' : 'scotland', 'consettstanleyadvertiser.co.uk' : 'north-east', 'advertiserseries.co.uk' : 'north-east', 'andoveradvertiser.co.uk' : 'south-east', 'asianimage.co.uk' : 'north-west', 'banburycake.co.uk' : 'oxfordshire-wiltshire', 'barryanddistrictnews.co.uk' : 'wales', 'basildonrecorder.co.uk' : 'south-east', 'eastbourneindependent.co.uk' : 'south-east', 'basingstokegazette.co.uk' : 'south-east', 'bicesteradvertiser.net' : 'oxfordshire-wiltshire', 'blackburncitizen.co.uk' : 'north-west', 'blackpoolcitizen.co.uk' : 'north-west', 'boatingcornwall.co.uk' : 'south-west', 'borehamwoodtimes.co.uk' : 'gloucestershire', 'bournemouthecho.co.uk' : 'south-east', 'bracknellnews.co.uk' : 'berkshire', 'braintreeandwithamtimes.co.uk' : 'south-east', 'brentwoodweeklynews.co.uk' : 'south-east', 'bridesdorset.co.uk' : 'south-east', 'brideshampshire.co.uk' : 'south-east', 'bridgwatermercury.co.uk' : 'south-west', 'bridportcarnival.co.uk' : 'south-east', 'bridportnews.co.uk' : 'south-east', 'bromsgroveadvertiser.co.uk' : 'midlands', 'bucksfreepress.co.uk' : 'london', 'burnhamandhighbridgeweeklynews.co.uk' : 'south-west', 'burnleycitizen.co.uk' : 'north-west', 'burytimes.co.uk' : 'north-west', 'businessdorset.co.uk' : 'south-east', 'campaignseries.co.uk' : 'wales', 'chardandilminsternews.co.uk' : 'south-west', 'chelmsfordweeklynews.co.uk' : 'south-east', 'chorleycitizen.co.uk' : 'north-west', 'clactonandfrintongazette.co.uk' : 'south-east', 'communitynewsgroup.co.uk' : 'north-west', 'congletonguardian.co.uk' : 'north-west', 'cotswoldjournal.co.uk' : 'midlands', 'cravenherald.co.uk' : 'north-east', 'creweguardian.co.uk' : 'north-west', 'croydonguardian.co.uk' : 'london', 'dailyecho.co.uk' : 'south-east', 'darlingtonandstocktontimes.co.uk' : 'north-east', 'dorsetecho.co.uk' : 'south-east', 'dorsetsociety.co.uk' : 'south-east', 'droitwichadvertiser.co.uk' : 'midlands', 'dudleynews.co.uk' : 'midlands', 'durhamtimes.co.uk' : 'north-east', 'ealingtimes.co.uk' : 'gloucestershire', 'echo-news.co.uk' : 'south-east', 'elmbridgeguardian.co.uk' : 'london', 'enfieldindependent.co.uk' : 'gloucestershire', 'eppingforestguardian.co.uk' : 'london', 'epsomguardian.co.uk' : 'london', 'essexcountystandard.co.uk' : 'south-east', 'eveningtimes.co.uk' : 'scotland', 'eveshamjournal.co.uk' : 'midlands', 'falmouthpacket.co.uk' : 'south-west', 'freepressseries.co.uk' : 'wales', 'gazetteandherald.co.uk' : 'oxfordshire-wiltshire', 'gazetteherald.co.uk' : 'north-east', 'gazette-news.co.uk' : 'south-east', 'gazetteseries.co.uk' : 'gloucestershire', 'guardian-series.co.uk' : 'gloucestershire', 'halesowennews.co.uk' : 'midlands', 'halsteadgazette.co.uk' : 'south-east', 'hampshirechronicle.co.uk' : 'south-east', 'hampshiresociety.co.uk' : 'south-east', 'haringeyindependent.co.uk' : 'gloucestershire', 'harrowtimes.co.uk' : 'gloucestershire', 'harwichandmanningtreestandard.co.uk' : 'south-east', 'heraldscotland.com' : 'scotland', 'heraldseries.co.uk' : 'oxfordshire-wiltshire', 'herefordtimes.com' : 'midlands', 'hillingdontimes.co.uk' : 'gloucestershire', 'hounslowandbrentfordtimes.co.uk' : 'london', 'ilkleygazette.co.uk' : 'north-east', 'keighleynews.co.uk' : 'north-east', 'kidderminstershuttle.co.uk' : 'midlands', 'kingstonguardian.co.uk' : 'london', 'knutsfordguardian.co.uk' : 'north-west', 'lancashiretelegraph.co.uk' : 'north-west', 'lancasterandmorecambecitizen.co.uk' : 'north-west', 'ledburyreporter.co.uk' : 'midlands', 'leighjournal.co.uk' : 'north-west', 'limitededitionsomerset.co.uk' : 'south-west', 'livingnortheast.co.uk' : 'north-east', 'localberkshire.co.uk' : 'berkshire', 'ludlowadvertiser.co.uk' : 'midlands', 'maldonandburnhamstandard.co.uk' : 'south-east', 'malverngazette.co.uk' : 'midlands', 'messengernewspapers.co.uk' : 'north-west', 'middevonstar.co.uk' : 'south-west', 'middlewichguardian.co.uk' : 'north-west', 'milfordmercury.co.uk' : 'wales', 'monmouthshirecountylife.co.uk' : 'wales', 'newburyandthatchamchronicle.co.uk' : 'berkshire', 'newforestpost.co.uk' : 'south-east', 'newsshopper.co.uk' : 'london', 'northernfarmer.co.uk' : 'north-east', 'northwichguardian.co.uk' : 'north-west', 'northyorkshireadvertiser.co.uk' : 'north-east', 'oxfordmail.co.uk' : 'oxfordshire-wiltshire', 'oxfordshireforums.co.uk' : 'oxfordshire-wiltshire', 'oxfordtimes.co.uk' : 'oxfordshire-wiltshire', 'penarthtimes.co.uk' : 'wales', 'prestoncitizen.co.uk' : 'north-west', 'prestwichandwhitefieldguide.co.uk' : 'north-west', 'readingchronicle.co.uk' : 'berkshire', 'redditchadvertiser.co.uk' : 'midlands', 'redhillandreigatelife.co.uk' : 'south-east', 'richmondandtwickenhamtimes.co.uk' : 'london', 'romseyadvertiser.co.uk' : 'south-east', 'runcornandwidnesworld.co.uk' : 'north-west', 's1homes.com' : 'scotland', 's1jobs.com' : 'scotland', 's1play.com' : 'scotland', 'salisburyjournal.co.uk' : 'south-east', 'sloughobserver.co.uk' : 'berkshire', 'smallholder.co.uk' : 'south-west', 'somersetcountygazette.co.uk' : 'south-west', 'southendstandard.co.uk' : 'south-east', 'southwalesargus.co.uk' : 'wales', 'southwalesguardian.co.uk' : 'wales', 'southwestfarmer.co.uk' : 'south-west', 'stainesguardian.co.uk' : 'london', 'stalbansreview.co.uk' : 'gloucestershire', 'sthelensstar.co.uk' : 'north-west', 'stourbridgenews.co.uk' : 'midlands', 'streathamguardian.co.uk' : 'london', 'stroudnewsandjournal.co.uk' : 'gloucestershire', 'surreycomet.co.uk' : 'london', 'suttonguardian.co.uk' : 'london', 'swanageandwarehamvoice.co.uk' : 'south-east', 'swindonadvertiser.co.uk' : 'oxfordshire-wiltshire', 'tewkesburyadmag.co.uk' : 'midlands', 'theadvertiserseries.co.uk' : 'north-east', 'theargus.co.uk' : 'south-east', 'theboltonnews.co.uk' : 'north-west', 'thelancasterandmorecambecitizen.co.uk' : 'north-west', 'thenorthernecho.co.uk' : 'north-east', 'thesouthernfarmer.co.uk' : 'south-east', 'thetelegraphandargus.co.uk' : 'north-east', 'thetottenhamindependent.co.uk' : 'london', 'thevillager.co.uk' : 'berkshire', 'thewestmorlandgazette.co.uk' : 'north-west', 'thisischeshire.co.uk' : 'north-west', 'thisisdorset.net' : 'south-east', 'thisishampshire.net' : 'south-east', 'thisislancashire.co.uk' : 'north-west', 'thisislocallondon.co.uk' : 'gloucestershire', 'thisisoxfordshire.co.uk' : 'oxfordshire-wiltshire', 'thisisswindontownfc.co.uk' : 'oxfordshire-wiltshire', 'thisisthewestcountry.co.uk' : 'south-west', 'thisiswiltshire.co.uk' : 'oxfordshire-wiltshire', 'thurrockgazette.co.uk' : 'south-east', 'times-series.co.uk' : 'gloucestershire', 'tivysideadvertiser.co.uk' : 'wales', 'wandsworthguardian.co.uk' : 'london', 'warringtonguardian.co.uk' : 'north-west', 'watfordobserver.co.uk' : 'gloucestershire', 'wearevoice.co.uk' : 'wales', 'westerntelegraph.co.uk' : 'wales', 'wharfedaleobserver.co.uk' : 'north-east', 'wilmslowguardian.co.uk' : 'north-west', 'wiltsglosstandard.co.uk' : 'gloucestershire', 'wiltshirebusinessonline.co.uk' : 'oxfordshire-wiltshire', 'wiltshiretimes.co.uk' : 'oxfordshire-wiltshire', 'wimbledonguardian.co.uk' : 'london', 'windsorobserver.co.uk' : 'berkshire', 'winsfordguardian.co.uk' : 'north-west', 'wirralglobe.co.uk' : 'north-west', 'witneygazette.co.uk' : 'oxfordshire-wiltshire', 'worcesternews.co.uk' : 'midlands', 'yeovilexpress.co.uk' : 'south-west', 'yorkpress.co.uk' : 'north-east', 'yourlocalguardian.co.uk' : 'london', 'brideandgroomoxfordshire.co.uk' : 'oxfordshire-wiltshire', 'fulhamguardian.co.uk' : 'london', 'greenguardian.co.uk' : 'london', 'livingnortheast.co.uk' : 'north-east', 'oxfordcitylife.co.uk' : 'oxfordshire-wiltshire', 's1cars.com' : 'scotland', 's1learning.com' : 'scotland', 's1rental.com' : 'scotland', 'thepeacegarden.co.uk' : 'north-east', 'airevalleyadvertiser.co.uk' : 'north-west', 'bridportcarnival.co.uk' : 'south-west', 'chesterlestreetadvertiser.co.uk' : 'north-east', 'communicationsjournal.co.uk' : 'london', 'consettstanleyadvertiser.co.uk' : 'north-east', 'darlingtonaycliffesedgefieldadvertiser.co.uk' : 'north-east', 'darlingtontogether.co.uk' : 'north-east', 'dorsetbeaches.co.uk' : 'south-east', 'durhamadvertiser.co.uk' : 'north-east', 'essexbusinessawards.co.uk' : 'south-east', 'essexfairsandevents.co.uk' : 'south-east', 'inbusinessessex.co.uk' : 'south-east', 'limitededitionsomerset.co.uk' : 'south-west', 'northernfarmer.co.uk' : 'north-east', 'northyorkshireadvertiser.co.uk' : 'north-east', 'readertrips.co.uk' : 'south-east', 'thebradfordadvertiser.co.uk' : 'north-east', 'thesouthernfarmer.co.uk' : 'south-west', 'walesfarmer.co.uk' : 'wales', 'wearvalleyadvertiser.co.uk' : 'north-east', 'yorkshirelivingonline.co.uk' : 'north-east' }; // prepare defaults rpx_params = { visitor : { age : '', gender : '', property : '', job : '', demographic : '' }, inventory : { region : '', section : '', site : '', weather : '', temperature : '', context : '', position : '' }, passback : { domain : '', position : '', size : '' } }; gpt = function(r) { // get gpt slot object g = window.frameElement; // get gpt slot id i = g.id.replace('google_ads_iframe_','').replace(new RegExp(/_[0-9]+/),''); m = g.id.match(/_[0-9]+/)[0].replace('_',''); y = (typeof parent.googletag !== 'undefined') ? parent.googletag.pubads().k : (typeof googletag !== 'undefined') ? googletag.pubads().k : { }; z = (typeof parent.googletag.slot_manager_instance !== 'undefined') ? parent.googletag.slot_manager_instance.find(i,m) : (typeof googletag.slot_manager_instance !== 'undefined') ? googletag.slot_manager_instance.find(i,m) : { d : '', z : '' }; // get gpt slot url for targeting params in query string if (['u','t'].indexOf(r) > -1) { gu = function() { rt = ''; for (var ky in z) { if (z.hasOwnProperty(ky) && typeof z[ky] === 'string') { if (z[ky].indexOf('//pubads.g.doubleclick.net') > -1) { rt = z[ky]; } } } return rt; } u = gu(); } // get gpt slot sizes if (['sz'].indexOf(r) > -1) { s = []; p = z.v; function gp(e,i,a) { s[i] = [e.getWidth(),e.getHeight()]; } p.forEach(gp); s = JSON.stringify(s); } // get gpt global targeting params if (['g'].indexOf(r) > -1) { gt = ''; for (var ky in y) { if (y.hasOwnProperty(ky) && typeof ky !== 'undefined') { if (y[ky] !== [] && y[ky] !== '' && y[ky] !== 'undefined' && y[ky].toString() !== '[]') { gt += '.setTargeting(\''+ky+'\',[\''+y[ky].join('\',\'')+'\'])'; } else { gt += '.setTargeting(\''+ky+'\','+y[ky]+')'; } } } } // get gpt local targeting params if (['u','t'].indexOf(r) > -1) { o = '', x = z.d; for (var ky in x) { if (x.hasOwnProperty(ky) && typeof ky !== 'undefined') { if (x[ky] !== [] && y[ky] !== '' && x[ky] !== 'undefined' && x[ky].toString() !== '[]') { o += '.setTargeting(\''+ky+'\',[\''+x[ky].join('\',\'')+'\'])'; } else { o += '.setTargeting(\''+ky+'\','+x[ky]+')'; } } } } // return requested resource if (r === 'id') { return i } if (r === 'u') { return u } if (r === 'sz') { return s } if (r === 't') { return o } if (r === 'g') { return gt } } rpd = function(d) { var a = ['596572', '596573', '596574', '596575', '596576', '596577', '596578']; // NQD: 18-24, 25-34, 35-44, 45-54, 55-59, 60-64, 65+ var g = ['596569', '596570']; // NQD: Female, Male var p = ['430728']; // AAM: Property Seeker var j = ['491990']; // AAM: Job Seeker if (d.indexOf(',') !== -1 ) { d = d.split(','); for (var i=0;i